package com.iwhalecloud.uncc.model;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;
import java.util.Date;

public class InsEventRecord implements Serializable ,ArchiverModel {


    private static final long serialVersionUID = -8514267148317652809L;
    private static final String PARAM_TASK_ID = "TASK_ID";
    private static final String PARAM_BATCH_ID = "BATCH_ID";
    private static final String PARAM_TACHE_INST_ID = "TACHE_INST_ID";
    private static final String PARAM_SOURCE_ID = "SOURCE_ID";
    private static final String PARAM_CMPT_ID = "CMPT_ID";
    private static final String PARAM_STRATEGY_ID = "STRATEGY_ID";
    private static final String PARAM_SERVICE_ID = "SERVICE_ID";
    private static final String PARAM_SERVICE_INST_ID = "SERVICE_INST_ID";
    private static final String PARAM_TRIGGER_POINT = "TRIGGER_POINT";
    private static final String PARAM_TEMPLATE_ID = "TEMPLATE_ID";
    private static final String PARAM_COLL_TEMPLATE_ID = "COLL_TEMPLATE_ID";

    private Long eventId;
    private Integer eventType;
    private Integer eventLevel;
    private Integer objectType;
    private String objectId;
    private String paramInfo;
    private String eventCode;
    private Date eventTime;
    private String eventState;
    private String operator;
    private Date operTime;
    private String partitionCode;
    private Date archiverTime;

    public Long getEventId() {
        return eventId;
    }

    public void setEventId(Long eventId) {
        this.eventId = eventId;
    }

    public Integer getEventType() {
        return eventType;
    }

    public void setEventType(Integer eventType) {
        this.eventType = eventType;
    }

    public Integer getEventLevel() {
        return eventLevel;
    }

    public void setEventLevel(Integer eventLevel) {
        this.eventLevel = eventLevel;
    }

    public Integer getObjectType() {
        return objectType;
    }

    public void setObjectType(Integer objectType) {
        this.objectType = objectType;
    }

    public String getObjectId() {
        return objectId;
    }

    public void setObjectId(String objectId) {
        this.objectId = objectId;
    }

    public String getParamInfo() {
        return paramInfo;
    }

    public void setParamInfo(String batchId, String taskId, String tacheInstId, String cmptId,
                             String sourceId, String strategyId, String templateId, String serviceId,
                             String serviceInstId, String triggerPoint,String collectTemplateId) {
        JSONObject json = new JSONObject();
        json.put(PARAM_TASK_ID, taskId);
        json.put(PARAM_BATCH_ID, batchId);
        json.put(PARAM_TACHE_INST_ID, tacheInstId);
        json.put(PARAM_CMPT_ID, cmptId);
        json.put(PARAM_SOURCE_ID, sourceId);
        json.put(PARAM_STRATEGY_ID, strategyId);
        json.put(PARAM_SERVICE_ID, serviceId);
        json.put(PARAM_SERVICE_INST_ID, serviceInstId);
        json.put(PARAM_TRIGGER_POINT, triggerPoint);
        json.put(PARAM_TEMPLATE_ID, templateId);
        if(StringUtils.isNotBlank(collectTemplateId)){
            json.put(PARAM_COLL_TEMPLATE_ID, collectTemplateId);
        }
        this.paramInfo = json.toJSONString();
    }

    public String getEventCode() {
        return eventCode;
    }

    public void setEventCode(String eventCode) {
        this.eventCode = eventCode;
    }

    public Date getEventTime() {
        return eventTime;
    }

    public void setEventTime(Date eventTime) {
        this.eventTime = eventTime;
    }

    public String getEventState() {
        return eventState;
    }

    public void setEventState(String eventState) {
        this.eventState = eventState;
    }

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public Date getOperTime() {
        return operTime;
    }

    public void setOperTime(Date operTime) {
        this.operTime = operTime;
    }

    public String getPartitionCode() {
        return partitionCode;
    }

    @Override
    public void setPartitionCode(String partitionCode) {
        this.partitionCode = partitionCode;
    }

    public void setParamInfo(String paramInfo) {
        this.paramInfo = paramInfo;
    }

    public Date getArchiverTime() {
        return archiverTime;
    }

    @Override
    public void setArchiverTime(Date archiverTime) {
        this.archiverTime = archiverTime;
    }
}
